-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Haque Farazul - Pet Park Assignment #21
base: main
Are you sure you want to change the base?
Conversation
enum animalType {None, Fish, Cat, Dog, Rabbit, Parrot} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommended to have enum names start with capital letters
gender _gender; | ||
uint age; | ||
address memberAddress; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Storage is costly in solidity. You don't need to store this address since you are already have the address as key in members mapping
} | ||
|
||
function animalCounts(animalType _animalType) public view returns (uint) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since solidity public mappings are automatically exposed as functions, you can just make animalCounts
as a public mapping
|
||
function add (animalType _animalType, uint _count) public{ | ||
require (owner == msg.sender, "Not an owner"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to use a modifier here for checking owner as it provides better code readability
|
||
|
||
function borrow (uint _age, gender _gender, animalType _animalType) public{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be marked external since it is not being called anywhere internally
No description provided.